1481B - New Colony - CodeForces Solution


brute force greedy implementation *1100

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>

using namespace std;
 
int main(){
   int t; cin>>t;
   while(t--){
    int n,k; cin>>n>>k;
    vector<int> v;
    for (int i = 0; i < n; i++){
        int m;cin>>m;v.push_back(m);
    }
   int store=-1;
   int check=0;
    for (int i = 0; i < k; i++){
        for(int j=0;j+1<n;j++){
                if(v[j]<v[j+1]){
                    check=0;
                    store=j+1;
                    v[j]++;
                    break;
                }
                check=1;
                store=-1;

        } 
        if(check) break;

          
    }
    cout<<store<<endl;


    
        }
    }   
  


Comments

Submit
0 Comments
More Questions

Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people
Book of Potion making
Duration
Birthday Party
e-maze-in
Bricks Game
Char Sum
Two Strings
Anagrams
Prime Number
Lexical Sorting Reloaded
1514A - Perfectly Imperfect Array
580A- Kefa and First Steps
1472B- Fair Division
996A - Hit the Lottery
MSNSADM1 Football
MATCHES Playing with Matches